﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZSZ.AdminWeb.App_Start;
using ZSZ.CommonMvc;
using ZSZ.Iservice;

namespace ZSZ.AdminWeb.Controllers
{
    public class HouseAppointmentController : Controller
    {
        public IAdminUserService AdminUserService { get; set; }
        public IHouseAppointmentService HouseAppointmentService { get; set; }
        
        // GET: HouseAppointment
        public ActionResult Index()
        {
            long? adminUserId = CommonAdmin.QuAdminUserId(HttpContext);
            var adminUser = AdminUserService.GetById((long)adminUserId);
            if (adminUser.CityID==null)
            {
                return Content("总部不能进行房源编辑");
            }
            var model =  HouseAppointmentService.GetPagedData((long)adminUser.CityID,"未处理",10,1);
            return View(model);
        }
        [HttpPost]
        public ActionResult Qiang(long id) {
            long? adminUserId = CommonAdmin.QuAdminUserId(HttpContext);
            if (HouseAppointmentService.Follow((long)adminUserId,id))
            {
                return Json(new JsonCommon { Status="ok"});
            }
            return Json(new JsonCommon { Status="err",ErrorMsg="抢单失败"});
        }
    }
}